<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_auction.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %> 
<%
	request.setCharacterEncoding("UTF-8");
	Hashtable ti_auction = new Hashtable();
	
	String req_auction_name="";
	
	String req_auction_desc="";
	
	String req_good_id="";
	
	String req_nowTime_e="",req_nowTime_s="",req_nowTime_n="";
	
	if(request.getParameter("req_nowTime_e")!=null && !request.getParameter("req_nowTime_e").equals("")){
		req_nowTime_e = request.getParameter("req_nowTime_e");
		ti_auction.put("req_nowTime_e",req_nowTime_e);
	}
	if(request.getParameter("req_nowTime_s")!=null && !request.getParameter("req_nowTime_s").equals("")){
		req_nowTime_s = request.getParameter("req_nowTime_s");
		ti_auction.put("req_nowTime_s",req_nowTime_s);
	}
	if(request.getParameter("req_nowTime_n")!=null && !request.getParameter("req_nowTime_n").equals("")){
		req_nowTime_n = request.getParameter("req_nowTime_n");
		ti_auction.put("req_nowTime_n",req_nowTime_n);
	}
	
	
	String good_id_1 = "";
	if(request.getParameter("good_id")!=null && !request.getParameter("good_id").equals("")){
		good_id_1 = request.getParameter("good_id");
		ti_auction.put("good_id",good_id_1);
	}

	
	if(request.getParameter("req_auction_name")!=null && !request.getParameter("req_auction_name").equals("")){
		req_auction_name = request.getParameter("req_auction_name");
		ti_auction.put("auction_name",req_auction_name);
	}
	
	if(request.getParameter("req_auction_desc")!=null && !request.getParameter("req_auction_desc").equals("")){
		req_auction_desc = request.getParameter("req_auction_desc");
		ti_auction.put("auction_desc",req_auction_desc);
	}
	
	if(request.getParameter("req_good_id")!=null && !request.getParameter("req_good_id").equals("")){
		req_good_id = request.getParameter("req_good_id");
		ti_auction.put("good_id",req_good_id);
	}
	String s_EndDate1 = "";
	if(request.getParameter("search_EndDate1")!=null && !request.getParameter("search_EndDate1").equals("")){
		s_EndDate1 = request.getParameter("search_EndDate1");
		ti_auction.put("end_date_1",s_EndDate1);
	}
	String s_EndDate2 = "";
	if(request.getParameter("search_EndDate2")!=null && !request.getParameter("search_EndDate2").equals("")){
		s_EndDate2 = request.getParameter("search_EndDate2");
		ti_auction.put("end_date_2",s_EndDate2);
	}
	String s_StartDate2 = "";
	if(request.getParameter("search_StartDate2")!=null && !request.getParameter("search_StartDate2").equals("")){
		s_StartDate2 = request.getParameter("search_StartDate2");
		ti_auction.put("start_date_2",s_StartDate2);
	}
	String s_StartDate1 = "";
	if(request.getParameter("search_StartDate1")!=null && !request.getParameter("search_StartDate1").equals("")){
		s_StartDate1 = request.getParameter("search_StartDate1");
		ti_auction.put("start_date_1",s_StartDate1);
	}	
//在xshell中打印	
	System.out.println("ti_auction: " + ti_auction);

	Ti_auctionInfo ti_auctionInfo = new Ti_auctionInfo();
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_auctionInfo.getListByPage(ti_auction,Integer.parseInt(iStart),limit);
	int counter = ti_auctionInfo.getCountByObj(ti_auction);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?req_auction_name="+req_auction_name+"&req_nowTime_e="+req_nowTime_e+"&req_nowTime_s="+ req_nowTime_s+"&req_nowTime_n="+ req_nowTime_n+"&iStart=",Integer.parseInt(iStart),limit);
	%>
<html>
  <head>
    
    <title>拍卖信息管理</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/js/commen.js"></script>
	<script type="text/javascript" src="auction.js"></script>
	<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>拍卖信息管理</h1>
			</td>
			<td>
				<a href="addInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
			 	  
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left" >
				
				
					活动名称:<input name="req_auction_name" type="text" />&nbsp;
		  		
					开始时间:&nbsp;
 <input name="search_StartDate1" type="text" id="search_StartDate1" class="Wdate" value="" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'search_StartDate2\',{d:-1})}',readOnly:true})" size="15"  width="150px"/>
				  -
 <input name="search_StartDate2" id="search_StartDate2" type="text" class="Wdate" value="" onclick="WdatePicker({minDate:'#F{$dp.$D(\'search_StartDate1\',{d:1})}',readOnly:true})" size="15" width="150px"/>
	  	  		
					结束时间:&nbsp;
  <input name="search_EndDate1" type="text" id="search_EndDate1" class="Wdate" value="" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'search_EndDate2\',{d:-1})}',readOnly:true})" size="15"  width="150px"/>
				  -
 <input name="search_EndDate2" id="search_EndDate2" type="text" class="Wdate" value="" onclick="WdatePicker({minDate:'#F{$dp.$D(\'search_EndDate1\',{d:1})}',readOnly:true})" size="15" width="150px"/>
	  			  		
				<input name="searchInfo" type="button" value="搜索" onclick="return search();"/>	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
			
		  	<th width="15%" >活动名称</th>
		  	
		  	<th>商品名称</th>

			<th width="15%">活动状态</th>
			
		  	<th>起拍价</th>
		  			  	
			<th>修改/查看</th>
	  		<th width="10%">删除</th>
		</tr>
		
		
		<% 
		  		String   nowTime="";
				for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
   String  good_id="",good_name="",auction_id="",auction_name="",auction_desc="",start_date="",end_date="",start_price="",a_price="",rate_price="",margin="",user_id="",in_date="";
		  			  	if(map.get("auction_id")!=null) auction_id = map.get("auction_id").toString();
  	if(map.get("auction_name")!=null) auction_name = map.get("auction_name").toString();
  	if(map.get("auction_desc")!=null) auction_desc = map.get("auction_desc").toString();
  	if(map.get("good_id")!=null) good_id = map.get("good_id").toString();
	
	if(map.get("good_name")!=null) {
		good_name = map.get("good_name").toString();
		if(good_name.length()>20) 
		good_name=good_name.substring(0,20);
	}
	if(map.get("start_date")!=null) start_date = map.get("start_date").toString();
	if(start_date.length()>19) start_date=start_date.substring(0,19);
  	if(map.get("end_date")!=null) end_date = map.get("end_date").toString();
	if(map.get("nowTime")!=null) 
	{
		nowTime = map.get("nowTime").toString();
	}
	
	if(end_date.length()>19)end_date=end_date.substring(0,19);
  	if(map.get("start_price")!=null) start_price = map.get("start_price").toString();
  	if(map.get("a_price")!=null) a_price = map.get("a_price").toString();
  	if(map.get("rate_price")!=null) rate_price = map.get("rate_price").toString();
  	if(map.get("margin")!=null) margin = map.get("margin").toString();
  	if(map.get("user_id")!=null) user_id = map.get("user_id").toString();
  	if(map.get("in_date")!=null) in_date = map.get("in_date").toString();
	if(in_date.length()>19)in_date=in_date.substring(0,19);

		  %>
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=auction_id %>" /></td>
			
		  	<td><a href="updateInfo.jsp?auction_id=<%=auction_id %>"><%=auction_name%></a></td>
		  			  			  	
		  	<td><%=good_name%></td>
		  	
		  	<td><%
			if(nowTime.compareTo(end_date) >= 0){
			%>
			<a href="index.jsp?req_nowTime_e=<%=nowTime%>">已结束</a>
			<%	
			}else if(nowTime.compareTo(start_date) < 0){
			%>
			<a href="index.jsp?req_nowTime_s=<%=nowTime%>">未开始</a>
			<%	
			}else{
			%>
			<a href="index.jsp?req_nowTime_n=<%=nowTime%>">活动进行中</a>
			<%}%>
			</td>
		  	
		  	<td><%=start_price%></td>  			  	
		  	
			<td ><a href="updateInfo.jsp?auction_id=<%=auction_id %>"><img src="/program/admin/images/edit.gif" title="修改" /></a> &nbsp;&nbsp;<a href="auctionLog.jsp?auction_id=<%=auction_id %>"><img src="/program/admin/images/view.gif" title="查看" /></a></td>
			<td width="10%"><a href="javascript:deleteOneInfo('<%=auction_id%>','1543');"><img src="/program/admin/images/delete.gif" title="删除" /></a></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="1543" />
	  </form>
</body>

</html>
